package cn.iocoder.an.module.mold.dal.mysql.linestopcategory;

import java.util.*;

import cn.iocoder.an.framework.common.pojo.PageResult;
import cn.iocoder.an.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.an.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.an.module.mold.dal.dataobject.linestopcategory.LinestopCategoryDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.an.module.mold.controller.admin.linestopcategory.vo.*;

/**
 * 停线类型 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface LinestopCategoryMapper extends BaseMapperX<LinestopCategoryDO> {

    default List<LinestopCategoryDO> selectList(LinestopCategoryListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<LinestopCategoryDO>()
                .likeIfPresent(LinestopCategoryDO::getName, reqVO.getName())
                .eqIfPresent(LinestopCategoryDO::getCode, reqVO.getCode())
                .eqIfPresent(LinestopCategoryDO::getParentId, reqVO.getParentId())
                .betweenIfPresent(LinestopCategoryDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(LinestopCategoryDO::getId));
    }

	default LinestopCategoryDO selectByParentIdAndName(Long parentId, String name) {
	    return selectOne(LinestopCategoryDO::getParentId, parentId, LinestopCategoryDO::getName, name);
	}

    default Long selectCountByParentId(Long parentId) {
        return selectCount(LinestopCategoryDO::getParentId, parentId);
    }

}